<template>

    <div style="flex-direction: column">

        <text class="title1" @click="dd">选择手机图片</text>
        <div style="flex-direction: row">
            <text class="title2" @click="ddaas">拍照测试</text>
            <text style="height: 100px;width: 1px;background-color: #ff0000;margin-top: 5px"></text>
            <text class="title2" @click="ddaas1">拍视频测试</text>
        </div>
        <text class="title1" @click="ddaa1">network模块</text>
        <text class="title1" @click="ddaa2">screen模块</text>
        <text class="title1" @click="ddaa3">video模块</text>
        <text class="title1" @click="ddaa4">volume模块</text>
        <text class="title1" @click="ddaa5">vibration模块</text>
        <text class="title1" @click="ddaa6">电池模块</text>

              <div style="flex-direction: row">
            <text class="title2" @click="ddaa7">录音模块开始</text>
            <text style="height: 100px;width: 1px;background-color: #ff0000;margin-top: 5px"></text>
            <text class="title2" @click="ddaa71">录音模块结束</text>
        </div>
                <text class="title1" @click="ddaa8">加速传感器</text>

               <text class="title1" @click="ddaa9">获取经纬度</text>
    </div>
</template>

<style>


    .title1 {
        width: 750px;
        height: 100px;
        display: flex;
        font-size: 30px;
        line-height: 100px;
        margin-top: 5px;
        color: #fff;
        text-align: center;
        background-color: #0088fb;
    }

    .title2 {
        width: 375px;
        height: 100px;
        display: flex;
        font-size: 30px;
        line-height: 100px;
        margin-top: 5px;
        color: #fff;
        text-align: center;
        background-color: #0088fb;
    }

</style>

<script>
    var mediaImg = weex.requireModule("nat/media/image");
    var camera = weex.requireModule("nat/camera");
    var network = weex.requireModule("nat/device/network");
    var screen = weex.requireModule("nat/device/screen");
    var video = weex.requireModule("nat/camera/video");
    var volume = weex.requireModule("nat/device/volume");
    var vibration = weex.requireModule("nat/device/vibration");
    var battery = weex.requireModule("nat/device/battery");
    var recorder = weex.requireModule("nat/recorder");
        var accelerometer = weex.requireModule("nat/sensor/accelerometer");
                var geolocation = weex.requireModule("nat/geolocation");
    var modal = weex.requireModule("modal");
    export default {
        data: {},
        methods: {
            dd: function (e) {
                mediaImg.pick({
                    limit: 6
                }, (res) => {
                    modal.toast({
                        message: JSON.stringify(res),
                        duration: 2
                    })

                })
            },
            ddaas: function (e) {
                camera.captureImage({
                    limit: 1
                }, (res) => {
                    modal.toast({
                        message: JSON.stringify(res),
                        duration: 2
                    })

                })
            },
            ddaas1: function (e) {
                camera.captureVideo({
                    limit: 1
                }, (res) => {
                    modal.toast({
                        message: JSON.stringify(res),
                        duration: 2
                    })

                })
            },
            ddaa1: function (e) {
                network.status((res) => {
                    modal.toast({
                        message: JSON.stringify(res),
                        duration: 2
                    })

                })
            },
            ddaa2: function (e) {
                screen.info((res) => {
                    modal.toast({
                        message: JSON.stringify(res),
                        duration: 2
                    })

                })


            },
            ddaa3: function (e) {

                video.play("http://flv2.bn.netease.com/videolib3/1611/01/XGqSL5981/SD/XGqSL5981-mobile.mp4", (res) => {
                    modal.toast({
                        message: JSON.stringify(res),
                        duration: 2
                    })

                })


            },
            ddaa4: function (e) {

                volume.get((res) => {
                    modal.toast({
                        message: JSON.stringify(res),
                        duration: 2
                    })

                })


            },
            ddaa5: function (e) {

                vibration.vibrate(1000, (res) => {
                    modal.toast({
                        message: JSON.stringify(res),
                        duration: 2
                    })

                })


            },
            ddaa6: function (e) {
                battery.status((res) => {
                    modal.toast({
                        message: JSON.stringify(res),
                        duration: 2
                    })

                })


            },
            ddaa7: function (e) {
                recorder.start({
                    channel: 'mono',
                    quality: 'high'
                }, (res) => {
                    modal.toast({
                        message: JSON.stringify(res),
                        duration: 2
                    })

                })


            },
            ddaa71: function (e) {
                recorder.stop((res) => {
                    modal.toast({
                        message: JSON.stringify(res),
                        duration: 2
                    })

                })


            },
            ddaa8: function (e) {
               accelerometer.watch({
               interval:2000
               },(res) => {
                    modal.toast({
                        message: JSON.stringify(res),
                        duration: 2
                    })
                })
            },
            ddaa9: function (e) {
               geolocation.get((res) => {
                    modal.toast({
                        message: JSON.stringify(res),
                        duration: 2
                    })
                })
            }
        }
    }
</script>